﻿using System;
using RpcHelper.Validate;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Model
{
        /// <summary>
        /// 任务步骤
        /// </summary>
        public class AddTaskItem
        {
                /// <summary>
                /// 任务Id
                /// </summary>
                [NullValidate ("rpc.task.id.null")]
                public Guid TaskId
                {
                        get;
                        set;
                }
                /// <summary>
                /// 任务项标题
                /// </summary>
                [NullValidate ("rpc.task.item.title.null")]
                [LenValidate ("rpc.task.item.title.len", 2, 50)]
                public string ItemTitle
                {
                        get;
                        set;
                }
                /// <summary>
                /// 步骤位
                /// </summary>
                [NumValidate ("rpc.task.item.sort.error", 1, int.MaxValue)]
                public int ItemSort
                {
                        get;
                        set;
                }
                /// <summary>
                /// 发送类型
                /// </summary>
                [EnumValidate("rpc.task.item.sendType.error",typeof(TaskSendType))]
                public TaskSendType SendType
                {
                        get;
                        set;
                }
                /// <summary>
                /// 发送参数
                /// </summary>
                [NullValidate ("rpc.task.item.send.param.null")]
                public TaskSendParam SendParam
                {
                        get;
                        set;
                }
                /// <summary>
                /// 超时时间
                /// </summary>
                [NumValidate ("rpc.task.item.timeout.error", 2, int.MaxValue)]
                public int? TimeOut
                {
                        get;
                        set;
                }
                /// <summary>
                /// 重试次数
                /// </summary>
                [NumValidate ("rpc.task.item.retry.error", 1, int.MaxValue)]
                public int? RetryNum
                {
                        get;
                        set;
                }
                /// <summary>
                /// 任务执行失败的步骤
                /// </summary>
                [EnumValidate ("rpc.task.item.fail.setup.error", typeof (TaskSetup))]
                public TaskSetup FailSetup
                {
                        get;
                        set;
                }
               /// <summary>
               /// 失败后执行的步骤
               /// </summary>
                [NumValidate ("rpc.task.fail.next.error", 1, int.MaxValue)]
                public int? FailNextSetup
                {
                        get;
                        set;
                }
                /// <summary>
                /// 成功执行的步骤
                /// </summary>
                [EnumValidate ("rpc.task.item.success.setup.error", typeof (TaskSetup))]
                public TaskSetup SuccessSetup
                {
                        get;
                        set;
                }
                /// <summary>
                /// 成功后执行的步骤
                /// </summary>
                [NumValidate ("rpc.task.success.next.error", 1, int.MaxValue)]
                public int? NextSetup
                {
                        get;
                        set;
                }
                /// <summary>
                /// 执行成功时是否写入日志
                /// </summary>
                public bool IsWriteLog
                {
                        get;
                        set;
                }
                /// <summary>
                /// 是否启用
                /// </summary>
                public bool IsEnable
                {
                        get;
                        set;
                }
        }
}
